#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>


int main()
{
    int sockfd = -1;
    struct sockaddr_in sockaddr;
    int ret = 0;
    char buf[20] = "";

    sockfd = socket(AF_INET,SOCK_STREAM,0);

    bzero(&sockaddr,sizeof(sockaddr));
    sockaddr.sin_family = AF_INET;
    sockaddr.sin_port = htons(9898);
    inet_aton("127.0.0.1",&sockaddr.sin_addr);

    ret = connect(sockfd,(struct sockaddr*)&sockaddr,sizeof(sockaddr));
    if(ret )
    {
	printf("in client , connect failed\n");
	close(sockfd);
	sockfd = -1;
	return 1;
    }

    write(sockfd,"hello",6);
    
    read(sockfd,buf,6);
    printf("Server Say To Me:%s\n",buf);

    
    close(sockfd);
    sockfd = -1;

    return 0;
}
